package com.lenovo.agricultureServer.http.action;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import com.lenovo.agricultureServer.ServerApp;

public class GetConfigAction extends BaseAction 
{
	public static final String TAG = "getConfig";
	
	private Context context;
	public GetConfigAction(Context context)
	{
		this.context = context;
	}
	
	@Override
	protected String jasonPorcess(String param) 
	{
		JSONObject jsonResponse = new JSONObject();
		try 
		{
			// 获取告警范围请求
			ServerApp app = (ServerApp)context;
			jsonResponse.put("minAirTemperature", app.getMinAirTemperature());
			jsonResponse.put("maxAirTemperature", app.getMaxAirTemperature());
			jsonResponse.put("minAirHumidity", app.getMinAirHumidity());
			jsonResponse.put("maxAirHumidity", app.getMaxAirHumidity());
			
			jsonResponse.put("minSoilTemperature", app.getMinEarthTemperature());
			jsonResponse.put("maxSoilTemperature", app.getMaxEarthTemperature());
			jsonResponse.put("minSoilHumidity", app.getMinEarthHumidity());
			jsonResponse.put("maxSoilHumidity", app.getMaxEarthHumidity());
			
			jsonResponse.put("minLight", app.getMinLight());
			jsonResponse.put("maxLight", app.getMaxLight());
			jsonResponse.put("minCo2", app.getMinCo2());
			jsonResponse.put("maxCo2", app.getMaxCo2());
			
			jsonResponse.put("maxPM25", app.getMaxPm25());
			jsonResponse.put("controlAuto", app.getControlAuto());
			
			jsonResponse.put("result", "ok");
			return jsonResponse.toString();
		} 
		catch (JSONException e) 
		{
			e.printStackTrace();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	protected String soapPorcess(String param) {
		//TODO
		return "";
	}

}
